package com.test.demo.service;

import com.test.demo.dao.entity.UserInfo;
import com.test.demo.dao.mapper.UserInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {

    @Resource
    private UserInfoMapper userInfoMapper;

    public static Long userId = 1L;

    public void insert() {
        for (int i = 1; i <= 10; i++) {
            UserInfo userInfo = new UserInfo();
            userInfo.setUserId(i + "");
            userInfo.setAccount("account" + i);
            userInfo.setPassword("password" + i);
            userInfo.setUserName("name" + i);
            userInfoMapper.insert(userInfo);
        }
    }

    public UserInfo getUserInfoByUserId(String id){
        return userInfoMapper.selectByPrimaryKey(id);
    }

    public List<UserInfo> getUserInfoByUserIds(String id){
        return userInfoMapper.selectByUserIds(id);
    }

    public List<UserInfo> selectByRange(Long firstId, Long lastId){
        return userInfoMapper.selectByRange(firstId, lastId);
    }
}
